{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">
                        <div class="layui-input-inline layui-form">
                            <select name="contract" lay-search="" class="layui-input">
                                <option value="">全部类型</option>
                                <option value="1">自营订单</option>
                                <option value="2">增补订单</option>
                            </select>
                        </div>
                        <div class="layui-input-inline layui-form">
                            <select name="type" id="n_range" lay-search="" class="layui-input">
                                <option value="">不限推送(增补类型)</option>
                                <option value="1">未推送</option>
                                <option value="2">已推送</option>
                            </select>
                        </div>
                        <div class="layui-input-inline layui-form">
                            <select name="cancelstatus" id="cancelstatus" lay-search="" class="layui-input">
                                <option value="">全部状态</option>
                                <option value="2">已拒绝</option>
                                <option value="3">已同意</option>
                                <option value="4">待审核</option>
                            </select>
                        </div>
                        <div class="layui-input-inline layui-form">
                            <select name="paystatus" id="paystatus" lay-search="" class="layui-input">
                                <option value="">不限打款</option>
                                <option value="1">无需打款</option>
                                <option value="2">未打款</option>
                                <option value="3">已打款</option>
                            </select>
                        </div>

                        <div class="layui-col-md6 layui-input-inline">
                            <input type="text" style="width: 300px;" id="n_title" class="layui-input search" name="n_title" placeholder="订单号/收件人姓名、手机号/快递单号/流水号"/>
                        </div>
                        <div class="layui-col-md6 layui-input-inline">
                            <input type="text" style="width: 90px;margin-left: 110px;" id="orderid" class="layui-input search" name="orderid" placeholder="订单id"/>
                        </div>
                        <!--退款审核-->
                        <div style="clear: both;height: 5px;"></div>
                        <div class="layui-input-inline layui-form" style="border: 1px solid mediumseagreen">
                            <select name="order_master_status" id="order_master_status" lay-search="" class="layui-input">
                                <option value="">不限退款状态</option>
                                <option value="1">退款同意|拒绝</option>
                                <option value="3">退款拒绝</option>
                                <option value="4">退款同意</option>
                            </select>
                        </div>
                        <div class="layui-input-inline" style="border: 1px solid mediumseagreen">
                            <input type="text"  name="start" onclick="wk.lay_date(this);" readonly class="layui-input layer-date search" placeholder="创建时间-起" />
                        </div>
                        <div class="layui-input-inline" style="border: 1px solid mediumseagreen">
                            <input type="text"  name="end" onclick="wk.lay_date(this);" readonly class="layui-input layer-date search" placeholder="创建时间-止" />
                        </div>
                        <div class="layui-input-inline">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button class="layui-btn layui-btn-normal" id="empty" lay-submit="" lay-filter="LAY-search">
                                重置
                            </button>
                        </div>
                    </div>
                </div>
                <!--搜索框结束-->
                <!--操作框开始-->
                <div class="col-sm-12">
                    <div class="input-group" >
                        <button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">
                            <i class="fa fa-wrench"></i> 导出 <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">
                            <li><a  href="javascript:;" class="layuiBtn" data-type="excelAll"><i class="fa fa-print"></i> 导出汇总</a></li>
                            <li><a  href="javascript:;" class="layuiBtn" data-type="excelAllDetail"><i class="fa fa-print"></i> 导出明细</a></li>
                        </ul>
                    </div>
                </div>
                <!--操作框结束-->
                <div class="col-sm-12">
                    <div class="input-group" >
                        <input type="text" disabled class="layui-input" id="tongji1" value="" style="border:1px solid red;color: red;width: 400px;" />
                    </div>
                </div>
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="testReload"></table>

                    <!--状态显示模板-->
                    <script type="text/html" id="pay_type">
                        {{# if(d.pay_type == 1){ }}
                        微信
                        {{# } }}
                        {{# if(d.pay_type == 2){ }}
                        支付宝
                        {{# } }}
                        {{# if(d.pay_type == 3){ }}
                        银联
                        {{# } }}
                    </script>

                    <!--状态显示模板-->
                    <script type="text/html" id="order_contract">
                        {{# if(d.order_contract == 1){ }}
                        自营订单
                        {{# } else {}}
                        增补订单
                        {{# } }}
                    </script>
                    <script type="text/html" id="order_push_erp">
                        {{# if(d.order_push_erp == 1){ }}
                        未推送
                        {{# } else {}}
                        已推送
                        {{# } }}
                    </script>
                    <script type="text/html" id="order_cancel_push_erp">
                        {{# if(d.order_cancel_push_erp == 1){ }}
                        未推送
                        {{# } else {}}
                        已推送
                        {{# } }}
                    </script>
                    <!--状态显示模板-->
                    <script type="text/html" id="order_cancel_status">
                        {{# if(d.order_cancel_status == 2){ }}
                        已拒绝
                        {{# } }}
                        {{# if(d.order_cancel_status == 3){ }}
                        已同意
                        {{# } }}
                        {{# if(d.order_cancel_status == 4){ }}
                        审核中
                        {{# } }}
                    </script>
                    <!--状态显示模板-->
                    <script type="text/html" id="updated_at">
                        {{# if(d.order_cancel_status == 3 && d.order_cancel_pay == 3){ }}
                        {{d.updated_at}}
                        {{# } else {}}
                        -
                        {{# } }}
                    </script>
                    <!--本身不同意的话就不会变为2 ，直接走这个值判断就行-->
                    <script type="text/html" id="order_cancel_pay">
                        {{# if(d.order_cancel_pay == 1){ }}
                        无需退款
                        {{# } }}
                        {{# if(d.order_cancel_pay == 2){ }}
                        未退款
                        {{# } }}
                        {{# if(d.order_cancel_pay == 3){ }}
                        已退款({{d.order_cancel_money}}元)
                        {{# } }}
                    </script>
                    <!--操作模板-->
                    <script type="text/html" id="opeBar">
                        <a href="javascript:;" onclick="wk.layer_show('详情','{:url('orderInfo')}?order_id={{d.order_id}}')" class="btn btn-primary btn-xs m-r-xs" title="详情"><i class="fa fa-info">详情</i></a>
                        {{# if(d.order_cancel_status == 4){ }}
                        <!--<a href="javascript:;" onclick="wk.layer_show('同意', '{:url('orderYesSend')}?order_id={{d.order_id}}')" class="btn btn-warning btn-xs m-r-xs" title="同意"><i class="fa fa-edit">同意</i></a>-->
                        <!--<a href="javascript:;" onclick="wk.layer_show('拒绝', '{:url('orderNo')}?order_id={{d.order_id}}')" class="btn btn-warning btn-xs m-r-xs" title="拒绝"><i class="fa fa-edit">拒绝</i></a>-->
                        <a href="javascript:;" onclick="wk.confirm('{{d.order_id}}','{:url('orderYesSend')}','确定同意吗？')" class="btn btn-warning btn-xs m-r-xs" title="同意"><i class="fa fa-edit">同意</i></a>
                        <a href="javascript:;" onclick="wk.confirm('{{d.order_id}}','{:url('orderNo')}','确定拒绝吗？')" class="btn btn-danger btn-xs m-r-xs" title="拒绝"><i class="fa fa-trash-o">拒绝</i></a>
                        {{# } }}
                        {{# if(d.order_cancel_pay == 2){ }}
                        {{# if(d.order_master_status == 1){ }}
                        <a href="javascript:;" onclick="wk.layer_show('退款申请', '{:url('orderTuiMoneyBefore')}?order_id={{d.order_id}}')" class="btn btn-warning btn-xs m-r-xs" title="退款申请"><i class="fa fa-edit">退款申请</i></a>
                        {{# } }}
                        {{# if(d.order_master_status == 2){ }}
                        <a href="javascript:;" class="btn btn-warning btn-xs m-r-xs" title="退款待审核">退款待审核</a>
                        {{# } }}
                        {{# if(d.order_master_status == 3){ }}
                        <a href="javascript:;" onclick="wk.layer_show('退款申请被拒，重新申请', '{:url('orderTuiMoneyBefore')}?order_id={{d.order_id}}')" class="btn btn-warning btn-xs m-r-xs" title="退款申请被拒，重新申请"><i class="fa fa-edit">重新退款</i></a>
                        {{# } }}
                        {{# } }}
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
<textarea id="allidsForOut" class="hidden"></textarea>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
            , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Ordercancel/index")}'
            , response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
//            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
                {type: 'checkbox', fixed: 'left',}
                , {type: 'numbers', width: 80, title: '序号'}
                , {field: 'order_no', width: '', title: '订单号', align: 'center'}
                , {field: 'order_back_order_id', width: '', title: '支付流水号', align: 'center'}
                , {field: 'order_contract', width: '', title: '订单类型', align: 'center', toolbar: '#order_contract'}
                , {field: 'first_good_name', width: '', title: '商品名字', align: 'center'}
                , {field: 'all_good_nums', width: '', title: '商品数量', align: 'center'}
                , {field: 'all_goods_price', width: '', title: '商品金额', align: 'center'}
                , {field: 'express_original_price', width: '', title: '运费', align: 'center'}
                , {field: 'total_price', width: '', title: '实付款', align: 'center'}
                , {field: 'user_username', width: '', title: '用户昵称', align: 'center'}
                , {field: 'user_phone', width: '', title: '用户手机号', align: 'center'}
                , {field: 'order_cancel_time', width: '', title: '创建时间', align: 'center'}
                , {field: 'tytime', width: '', title: '同意时间', align: 'center'}
                , {field: 'updated_at', width: '', title: '打款时间', align: 'center', toolbar: '#updated_at'}
                , {field: 'pay_type', width: '', title: '支付类型', align: 'center', toolbar: '#pay_type'}
                , {field: 'order_push_erp', width: '', title: '原单推送', align: 'center', toolbar: '#order_push_erp'}
                , {field: 'order_cancel_push_erp', width: '', title: '取消推送', align: 'center', toolbar: '#order_cancel_push_erp'}
                , {field: 'order_cancel_status', width: '', title: '是否同意', align: 'center', toolbar: '#order_cancel_status'}
                , {field: 'order_cancel_pay', width: '', title: '是否打款', align: 'center', toolbar: '#order_cancel_pay'}
                , {fixed: 'right', width: 200, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            , done: function (res, curr, count) {
                $('.img-circle').viewer({
                    url: 'data-original',
                });
                $('#tongji1').val('当前条件下总金额：'+res.money+'元');
            }
        });
        //监听状态开关操作
        form.on('switch(OnOff)', function (obj) {
            var num = '';
            obj.elem.checked == true? num = 1: num = 2;
            //用户状态
            wk.status(this.value,num, '{:url("changeGoodStatus")}',obj);
        });
        //批量操作
        var $ = layui.$, active = {
            excelAll: function(){
                //导出Excel
                wk.excelAll('',$('.layui-input').serialize(),"{:url('excelOutOrder')}");
            },
            excelAllDetail: function(){
                //导出Excel
                wk.excelAll('',$('.layui-input').serialize(),"{:url('excelOutDetail')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                , data = checkStatus.data;
            $.each(data, function (index, item) {
                ids.push(item['n_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>